﻿@using JewererBasic.Models
@using Zen.Barcode.Web.Mvc
@using Zen.Barcode
@using Zen.Barcode.Web

@model JewererBasic.BAG

@{
    var gd = new WebGrid(
            Model.BAG_PROCESS.Where(m => m.PROCESS.Type == 1),
            canPage: true,
            rowsPerPage: 20,
            selectionFieldName: "selectedRow",
            ajaxUpdateContainerId: "gridContent"
        );
    gd.Pager(WebGridPagerModes.NextPrevious);
}


<div id="bag">
    <table style="border: 1px solid black;">
        <tr style="border: 1px solid black;">
            <td style="vertical-align: top;">
                <div>
                    <table style="border: 1px solid black">
                        <tr>
                            <td colspan="4">
                                <div>
                                    <table>
                                        <tr>
                                            <td>
                                                <strong><u>Bag No:</u></strong>@Html.TextBox("BagId", Model.Id, new { @readonly = "readonly", @style = "display: none" })
                                            </td>
                                            <td style="width: 190px; border: 2px solid black; text-align: center">
                                                <strong>@Model.Id</strong>
                                            </td>
                                            <td>
                                                <strong><u>Finish:</u>&nbsp;<strong>WEEK</strong>&nbsp;@Model.ORDER_PRODUCT.ORDER.FinishWeek</strong>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <div>
                                    <table>
                                        <tr>
                                            <th style="width: 60px"></th>
                                            <th style="width: 100px"></th>
                                            <th style="width: 140px"></th>
                                            <th style="width: 120px"></th>
                                        </tr>
                                        <tr>
                                            <td colspan="2">
                                                <strong><u>Item:</u></strong> @Html.DisplayFor(m => m.ORDER_PRODUCT.IdProduct)
                                            </td>
                                            <td>
                                                <strong><u>Gold:</u></strong> @ViewBag.KindName
                                            </td>
                                            <td rowspan="5">
                                                <img src="@Url.Content(String.Format("~/Uploads/{0}", Model.ORDER_PRODUCT.PRODUCT.Drawing))" width="120" height="120" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <strong><u>Qty:</u></strong> @Html.DisplayFor(m => m.Number)
                                            </td>
                                            <td>
                                                <strong><u>Type:</u></strong> @Html.DisplayFor(m => m.ORDER_PRODUCT.PRODUCT.TYPE.Name)
                                            </td>
                                            <td>
                                                <strong><u>Order No:</u></strong> @Html.DisplayFor(m => m.ORDER_PRODUCT.IdOrder)
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2">
                                                <strong><u>Size:</u></strong> @Html.DisplayFor(m => m.ORDER_PRODUCT.Size)
                                            </td>
                                            <td>
                                                <strong><u>Custom:</u></strong> @Html.DisplayFor(m => m.ORDER_PRODUCT.ORDER.IdCustomer)
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2">
                                                <strong><u>Casting No:</u></strong>
                                            </td>
                                            <td>
                                                <strong><u>Gamma:</u></strong> @Html.DisplayFor(m => m.ORDER_PRODUCT.PRODUCT.GAMMA.Name)
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="4">
                                                @foreach (var item in Model.BAG_MOULD)
                                                {
                                                    <text> @item.Numb _ @item.IdMould </text><br />
                                                }
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="4">
                                                <strong><u>Stone:</u></strong><br />
                                                @foreach (var item in Model.BAG_STONE)
                                                {
                                                    <text>@item.TotalQty _ @item.IdStone: @item.STONE.Name </text><br />
                                                }
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="4">
                                                <strong><u>Remark:</u></strong><br />
                                                @Html.TextAreaFor(m => m.ORDER_PRODUCT.PRODUCT.Remark, new { @readonly = "readonly", @style = "width: 470px; min-width:470px; max-width:500px; height:100px; min-height:100px; max-height:100px;" })
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <strong><u>Process:</u></strong>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="text-align: center" colspan="4">
                                                <img src="@Url.Content(String.Format("~/Content/Barcode/{0}", Model.ORDER_PRODUCT.IdOrder + "_" + Model.Id + ".png"))"/>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </td>
                        </tr>
                    </table>
                </div>
            </td>
            <td style="border: 1px solid black; vertical-align: top;">
                <div id="dataProcesses">
                    <div style="height: 25px;"><span id="errorWeight" style="display: none; color: red">The weight in is only bigger or equal than the weight out.</span><span id="errorDate" style="display: none; color: red">The date in is only smaller or equal than the date out.</span></div>
                    @gd.GetHtml(
                        tableStyle: "table",
                        headerStyle: "head",
                        rowStyle: "row",
                        alternatingRowStyle: "altRow",
                        selectedRowStyle: "selectRow",
                        columns: gd.Columns(
                        gd.Column(header: "Description", format: @<div style="width: 150px; text-align: center;">@item.PROCESS.Name</div>),
                        gd.Column(header: "Time", format: @<div style="width: 70px; text-align: center;">@item.Time</div>),
                        gd.Column(header: "Worker ID", format: @<div style="width: 100px; text-align: center;"><span id="spanWorkerId_@item.IdProcess">@item.WorkerId</span></div>),
                        gd.Column(header: "Weight IN", format: @<div style="width: 100px; text-align: center;"><span id="spanWeightIN_@item.IdProcess">@item.WeightIn</span></div>),
                        gd.Column(header: "Date IN", format: @<div style="width: 100px;">
                            <div id="spanDateIN_@item.IdProcess" style="text-align:center">@(((DateTime?)item.DateIn).HasValue ? ((DateTime?)item.DateIn).Value.ToString("MM/dd/yyyy") : "")</div>
                        </div>),
                        gd.Column(header: "Weight OUT", format: @<div style="width: 100px; text-align: center;"><span id="spanWeightOUT_@item.IdProcess">@item.WeightOut</span></div>),
                        gd.Column(header: "Date OUT", format: @<div style="width: 100px;">
                            <div id="spanDateOUT_@item.IdProcess" style="text-align: center;">@(((DateTime?)item.DateOut).HasValue ? ((DateTime?)item.DateOut).Value.ToString("MM/dd/yyyy") : "")</div>
                        </div>)
                    ))
                </div>
            </td>
        </tr>
    </table>
</div>
